{ "cells": [ { "cell_type": "code", "execution_count": 1, "id": "d5330bc4-7331-45ea-a340-11326e6a6b6c", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Working on a Windows 10\n", "Python version 3.11.7 | packaged by Anaconda, Inc. | (main, Dec 15 2023, 18:05:47) [MSC v.1916 64 bit (AMD64)]\n", "Pandas version 2.1.4\n", "bifacial_radiance version 0+untagged.1553.g23d2640.dirty\n" ] } ], "source": [ "# This information helps with debugging and getting support :)\n", "import sys, platform\n", "import pandas as pd\n", "import bifacial_radiance as br\n", "print(\"Working on a \", platform.system(), platform.release())\n", "print(\"Python version \", sys.version)\n", "print(\"Pandas version \", pd.__version__)\n", "print(\"bifacial_radiance version \", br.__version__)" ] }, { "cell_type": "markdown", "id": "4997ec7a", "metadata": {}, "source": [ "## 17 - AgriPV - Jack Solar Site Modeling" ] }, { "cell_type": "markdown", "id": "393445a3", "metadata": {}, "source": [ "Modeling Jack Solar AgriPV site in Longmonth CO, for crop season May September. The site has two configurations:\n", "\n", "\n", " Configuration A: \n", "* Under 6 ft panels : 1.8288m\n", "* Hub height: 6 ft : 1.8288m \n", "\n", " \n", "Configuration B:\n", "* 8 ft panels : 2.4384m\n", "* Hub height 8 ft : 2.4384m\n", "\n", "Other general parameters:\n", "* Module Size: 3ft x 6ft (portrait mode)\n", "* Row-to-row spacing: 17 ft --> 5.1816\n", "* Torquetube: square, diam 15 cm, zgap = 0\n", "* Albedo = green grass\n", " \n", "\n", "### Steps in this Journal:\n", "1. Load Bifacial Radiance and other essential packages\n", "2. Define all the system variables \n", "3. Build Scene for a pretty Image \n", "\n", "\n", "#### More details\n", "There are three methods to perform the following analyzis: \n", "* A. Hourly with Fixed tilt, getTrackerAngle to update tilt of tracker \n", "* B. Hourly with gendaylit1axis using the tracking dictionary \n", "* C. Cumulatively with gencumsky1axis \n", "\n", " \n", "The analysis itself is performed with the HPC with method A, and results are compared to GHI (equations below). The code below shows how to build the geometry and view it for accuracy, as well as evaluate monthly GHI, as well as how to model it with `gencumsky1axis` which is more suited for non-hpc environments. \n", "\n", "\n", "\n", "![AgriPV Jack Solar Study](../images_wiki/AdvancedJournals/AgriPV_JackSolar.PNG)\n" ] }, { "cell_type": "markdown", "id": "e588c612", "metadata": {}, "source": [ "" ] }, { "cell_type": "markdown", "id": "2b900d27", "metadata": {}, "source": [ "## 1. Load Bifacial Radiance and other essential packages" ] }, { "cell_type": "code", "execution_count": 1, "id": "c3575599", "metadata": {}, "outputs": [], "source": [ "import bifacial_radiance\n", "import numpy as np\n", "import os # this operative system to do the relative-path testfolder for this example.\n", "import pprint # We will be pretty-printing the trackerdictionary throughout to show its structure.\n", "from pathlib import Path\n", "import pandas as pd" ] }, { "cell_type": "markdown", "id": "fb7ae004", "metadata": {}, "source": [ "" ] }, { "cell_type": "markdown", "id": "149f51b2", "metadata": {}, "source": [ "## 2. Define all the system variables" ] }, { "cell_type": "code", "execution_count": 2, "id": "b6f8ac23", "metadata": {}, "outputs": [], "source": [ "testfolder = str(Path().resolve().parent.parent / 'bifacial_radiance' / 'Tutorial_17')\n", "if not os.path.exists(testfolder):\n", " os.makedirs(testfolder)\n", " \n", "timestamp = 4020 # Noon, June 17th.\n", "simulationName = 'tutorial_17' # Optionally adding a simulation name when defning RadianceObj\n", "\n", "#Location\n", "lat = 40.1217 # Given for the project site at Colorado\n", "lon = -105.1310 # Given for the project site at Colorado\n", "\n", "# MakeModule Parameters\n", "moduletype='test-module'\n", "numpanels = 1 # This site have 1 module in Y-direction\n", "x = 1 \n", "y = 2\n", "#xgap = 0.15 # Leaving 15 centimeters between modules on x direction\n", "#ygap = 0.10 # Leaving 10 centimeters between modules on y direction\n", "zgap = 0 # no gap to torquetube.\n", "sensorsy = 6 # this will give 6 sensors per module in y-direction\n", "sensorsx = 3 # this will give 3 sensors per module in x-direction\n", "\n", "torquetube = True\n", "axisofrotationTorqueTube = True \n", "diameter = 0.15 # 15 cm diameter for the torquetube\n", "tubetype = 'square' # Put the right keyword upon reading the document\n", "material = 'black' # Torque tube of this material (0% reflectivity)\n", "\n", "# Scene variables\n", "nMods = 20\n", "nRows = 7\n", "hub_height = 1.8 # meters\n", "pitch = 5.1816 # meters # Pitch is the known parameter \n", "albedo = 0.2 #'Grass' # ground albedo\n", "gcr = y/pitch\n", "\n", "cumulativesky = False\n", "limit_angle = 60 # tracker rotation limit angle\n", "angledelta = 0.01 # we will be doing hourly simulation, we want the angle to be as close to real tracking as possible.\n", "backtrack = True " ] }, { "cell_type": "code", "execution_count": 3, "id": "95bd8cae", "metadata": {}, "outputs": [], "source": [ "test_folder_fmt = 'Hour_{}' " ] }, { "cell_type": "markdown", "id": "eb8cef29", "metadata": {}, "source": [ "" ] }, { "cell_type": "markdown", "id": "c15854db", "metadata": {}, "source": [ "## 3. Build Scene for a pretty Image" ] }, { "cell_type": "code", "execution_count": 6, "id": "9b8ec54c", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "path = C:\\Users\\mprillim\\sam_dev\\bifacial_radiance\\bifacial_radiance\\Tutorial_17\\Hour_0272\n", "Loading albedo, 1 value(s), 0.200 avg\n", "1 nonzero albedo values.\n", "Getting weather file: USA_CO_Boulder-Broomfield-Jefferson.County.AP.724699_TMY3.epw\n", " ... OK!\n", "8760 line in WeatherFile. Assuming this is a standard hourly WeatherFile for the year for purposes of saving Gencumulativesky temporary weather files in EPW folder.\n", "Coercing year to 2021\n", "Saving file EPWs\\metdata_temp.csv, # points: 8760\n", "Calculating Sun position for center labeled data, at exact timestamp in input Weather File\n", "Created tutorial_17.oct\n" ] } ], "source": [ "idx = 272\n", "\n", "test_folderinner = os.path.join(testfolder, test_folder_fmt.format(f'{idx:04}'))\n", "if not os.path.exists(test_folderinner):\n", " os.makedirs(test_folderinner)\n", "\n", "rad_obj = bifacial_radiance.RadianceObj(simulationName,path = test_folderinner) # Create a RadianceObj 'object'\n", "rad_obj.setGround(albedo) \n", "epwfile = rad_obj.getEPW(lat,lon) \n", "metdata = rad_obj.readWeatherFile(epwfile, label='center', coerce_year=2021)\n", "solpos = rad_obj.metdata.solpos.iloc[idx]\n", "zen = float(solpos.zenith)\n", "azm = float(solpos.azimuth) - 180\n", "dni = rad_obj.metdata.dni[idx]\n", "dhi = rad_obj.metdata.dhi[idx]\n", "rad_obj.gendaylit(idx)\n", "# rad_obj.gendaylit2manual(dni, dhi, 90 - zen, azm)\n", "#print(rad_obj.metdata.datetime[idx])\n", "tilt = round(rad_obj.getSingleTimestampTrackerAngle(metdata, timeindex=idx, gcr=gcr, limit_angle=65),1)\n", "sceneDict = {'pitch': pitch, 'tilt': tilt, 'azimuth': 90, 'hub_height':hub_height, 'nMods':nMods, 'nRows': nRows} \n", "scene = rad_obj.makeScene(module=moduletype,sceneDict=sceneDict)\n", "octfile = rad_obj.makeOct() " ] }, { "cell_type": "markdown", "id": "c9ea4ec1", "metadata": {}, "source": [ "**The scene generated can be viewed by navigating on the terminal to the testfolder and typing**\n", "\n", "> rvu -vf views\\front.vp -e .0265652 -vp 2 -21 2.5 -vd 0 1 0 tutorial_17.oct\n", "\n", "**OR Comment the ! line below to run rvu from the Jupyter notebook instead of your terminal.**\n" ] }, { "cell_type": "code", "execution_count": 7, "id": "64409ab7", "metadata": {}, "outputs": [], "source": [ "\n", "## Comment the ! line below to run rvu from the Jupyter notebook instead of your terminal.\n", "## Simulation will stop until you close the rvu window\n", "\n", "#!rvu -vf views\\front.vp -e .0265652 -vp 2 -21 2.5 -vd 0 1 0 tutorial_17.oct\n" ] }, { "cell_type": "markdown", "id": "b34795bc", "metadata": {}, "source": [ "" ] }, { "cell_type": "markdown", "id": "d47847e9", "metadata": {}, "source": [ "## GHI Calculations \n" ] }, { "cell_type": "markdown", "id": "115de65f", "metadata": {}, "source": [ "### From Weather File" ] }, { "cell_type": "code", "execution_count": 8, "id": "fe74ab01", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ " GHI Boulder Monthly May to September Wh/m2: [196632, 206257, 201029, 176973, 146532]\n" ] } ], "source": [ "# BOULDER\n", "# Simple method where I know the index where the month starts and collect the monthly values this way.\n", "\n", "# In 8760 TMY, this were the indexes:\n", "starts = [2881, 3626, 4346, 5090, 5835]\n", "ends = [3621, 4341, 5085, 5829, 6550]\n", "\n", "starts = [metdata.datetime.index(pd.to_datetime('2021-05-01 6:0:0 -7')),\n", " metdata.datetime.index(pd.to_datetime('2021-06-01 6:0:0 -7')),\n", " metdata.datetime.index(pd.to_datetime('2021-07-01 6:0:0 -7')),\n", " metdata.datetime.index(pd.to_datetime('2021-08-01 6:0:0 -7')),\n", " metdata.datetime.index(pd.to_datetime('2021-09-01 6:0:0 -7'))]\n", "\n", "ends = [metdata.datetime.index(pd.to_datetime('2021-05-31 18:0:0 -7')),\n", " metdata.datetime.index(pd.to_datetime('2021-06-30 18:0:0 -7')),\n", " metdata.datetime.index(pd.to_datetime('2021-07-31 18:0:0 -7')),\n", " metdata.datetime.index(pd.to_datetime('2021-08-31 18:0:0 -7')),\n", " metdata.datetime.index(pd.to_datetime('2021-09-30 18:0:0 -7'))]\n", "\n", "ghi_Boulder = []\n", "for ii in range(0, len(starts)):\n", " start = starts[ii]\n", " end = ends[ii]\n", " ghi_Boulder.append(metdata.ghi[start:end].sum())\n", "print(\" GHI Boulder Monthly May to September Wh/m2:\", ghi_Boulder)\n" ] }, { "cell_type": "markdown", "id": "e8347875", "metadata": {}, "source": [ "### With raytrace" ] }, { "cell_type": "code", "execution_count": 9, "id": "db6fe1f4", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "path = C:\\Users\\mprillim\\sam_dev\\bifacial_radiance\\bifacial_radiance\\Tutorial_17\\Hour_0272\n", "Loading albedo, 1 value(s), 0.200 avg\n", "1 nonzero albedo values.\n", "8760 line in WeatherFile. Assuming this is a standard hourly WeatherFile for the year for purposes of saving Gencumulativesky temporary weather files in EPW folder.\n", "Coercing year to 2021\n", "Filtering dates\n", "Saving file EPWs\\metdata_temp.csv, # points: 8760\n", "Calculating Sun position for center labeled data, at exact timestamp in input Weather File\n", "Loaded EPWs\\metdata_temp.csv\n", "message: There were 461 sun up hours in this climate file\n", "Total Ibh/Lbh: 0.000000\n", "Created EMPTYFIELD_MAY.oct\n", "Linescan in process: FIELDTotal_Front\n", "Linescan in process: FIELDTotal_Back\n", "Saved: results\\irr_FIELDTotal.csv\n", "FIELD TOTAL MAY: 194047.0\n" ] } ], "source": [ "simulationName = 'EMPTYFIELD_MAY'\n", "starttime = pd.to_datetime('2021-05-01 6:0:0')\n", "endtime = pd.to_datetime('2021-05-31 18:0:0')\n", "rad_obj = bifacial_radiance.RadianceObj(simulationName) \n", "rad_obj.setGround(albedo) \n", "metdata = rad_obj.readWeatherFile(epwfile, label='center', coerce_year=2021, starttime=starttime, endtime=endtime)\n", "rad_obj.genCumSky()\n", "#print(rad_obj.metdata.datetime[idx])\n", "sceneDict = {'pitch': pitch, 'tilt': 0, 'azimuth': 90, 'hub_height':-0.2, 'nMods':1, 'nRows': 1} \n", "scene = rad_obj.makeScene(module=moduletype,sceneDict=sceneDict)\n", "octfile = rad_obj.makeOct() \n", "analysis = bifacial_radiance.AnalysisObj()\n", "frontscan, backscan = analysis.moduleAnalysis(scene, sensorsy=1)\n", "frontscan['zstart'] = 0.5\n", "frontdict, backdict = analysis.analysis(octfile = octfile, name='FIELDTotal', frontscan=frontscan, backscan=backscan)\n", "print(\"FIELD TOTAL MAY:\", analysis.Wm2Front[0])" ] }, { "cell_type": "markdown", "id": "20124dbc", "metadata": {}, "source": [ "## Next STEPS: Raytrace Every hour of the Month on the HPC -- Check HPC Scripts for Jack Solar" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.11.7" }, "vscode": { "interpreter": { "hash": "14c04630f1cd445b2532d35c77825134bfcafda47af70d0b9c2b5023b1f357a5" } } }, "nbformat": 4, "nbformat_minor": 5 }